From d295bc4de48ff7926855c989b836a55585c4a1a7 Mon Sep 17 00:00:00 2001 From: Jimi Xenidis Date: Mon, 2 Oct 2006 21:40:26 -0400 Subject: [PATCH] [XEN][POWERPC] Use gmfn_to_mfn() over pfn2mfn() Should only use pfn2mfn() if you care about the type of memory. Signed-off-by: Jimi Xenidis Signed-off-by: Hollis Blanchard --- xen/arch/powerpc/iommu.c | 7 +++---- xen/arch/powerpc/usercopy.c | 28 ++++------------------------ xen/include/asm-powerpc/debugger.h | 5 ++++- xen/include/asm-powerpc/mm.h | 17 ++++++++++++++++- xen/include/asm-powerpc/page.h | 2 ++ 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/xen/arch/powerpc/iommu.c b/xen/arch/powerpc/iommu.c index 5086bf0ebf..a6c5fa093f 100644 --- a/xen/arch/powerpc/iommu.c +++ b/xen/arch/powerpc/iommu.c @@ -46,12 +46,11 @@ int iommu_put(u32 buid, ulong ioba, union tce tce) struct domain *d = v->domain; if (buid < iommu_phbs_num && iommu_phbs[buid].iommu_put != NULL) { - ulong pfn; + ulong gpfn; ulong mfn; - int mtype; - pfn = tce.tce_bits.tce_rpn; - mfn = pfn2mfn(d, pfn, &mtype); + gpfn = tce.tce_bits.tce_rpn; + mfn = gmfn_to_mfn(d, gpfn); if (mfn != INVALID_MFN) { #ifdef DEBUG printk("%s: ioba=0x%lx pfn=0x%lx mfn=0x%lx\n", __func__, diff --git a/xen/arch/powerpc/usercopy.c b/xen/arch/powerpc/usercopy.c index bb96d23b3c..d7e33bcff0 100644 --- a/xen/arch/powerpc/usercopy.c +++ b/xen/arch/powerpc/usercopy.c @@ -39,40 +39,20 @@ static unsigned long paddr_to_maddr(unsigned long paddr) { struct vcpu *v = get_current(); struct domain *d = v->domain; - int mtype; - ulong pfn; + ulong gpfn; ulong offset; ulong pa = paddr; offset = pa & ~PAGE_MASK; - pfn = pa >> PAGE_SHIFT; + gpfn = pa >> PAGE_SHIFT; - pa = pfn2mfn(d, pfn, &mtype); + pa = gmfn_to_mfn(d, gpfn); if (pa == INVALID_MFN) { printk("%s: Dom:%d bad paddr: 0x%lx\n", __func__, d->domain_id, paddr); return 0; } - switch (mtype) { - case PFN_TYPE_RMA: - case PFN_TYPE_LOGICAL: - break; - - case PFN_TYPE_FOREIGN: - /* I don't think this should ever happen, but I suppose it - * could be possible */ - printk("%s: Dom:%d paddr: 0x%lx type: FOREIGN\n", - __func__, d->domain_id, paddr); - WARN(); - break; - - case PFN_TYPE_IO: - default: - printk("%s: Dom:%d paddr: 0x%lx bad type: 0x%x\n", - __func__, d->domain_id, paddr, mtype); - WARN(); - return 0; - } + pa <<= PAGE_SHIFT; pa |= offset; diff --git a/xen/include/asm-powerpc/debugger.h b/xen/include/asm-powerpc/debugger.h index ec77526874..6fea7a3958 100644 --- a/xen/include/asm-powerpc/debugger.h +++ b/xen/include/asm-powerpc/debugger.h @@ -13,14 +13,17 @@ * along with this program; if not, write to the Free Software * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Copyright (C) IBM Corp. 2005 + * Copyright (C) IBM Corp. 2005, 2006 * * Authors: Hollis Blanchard + * Jimi Xenidis */ #ifndef _ASM_DEBUGGER_H_ #define _ASM_DEBUGGER_H_ +#include + extern void show_backtrace_regs(struct cpu_user_regs *); extern void show_backtrace(ulong sp, ulong lr, ulong pc); diff --git a/xen/include/asm-powerpc/mm.h b/xen/include/asm-powerpc/mm.h index 094945e2fe..8c3d228d67 100644 --- a/xen/include/asm-powerpc/mm.h +++ b/xen/include/asm-powerpc/mm.h @@ -247,7 +247,22 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg); static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn) { - return pfn2mfn(d, gmfn, NULL); + int mtype; + ulong mfn; + + mfn = pfn2mfn(d, gmfn, &mtype); + if (mfn != INVALID_MFN) { + switch (mtype) { + case PFN_TYPE_RMA: + case PFN_TYPE_LOGICAL: + break; + default: + WARN(); + mfn = INVALID_MFN; + break; + } + } + return mfn; } #define mfn_to_gmfn(_d, mfn) (mfn) diff --git a/xen/include/asm-powerpc/page.h b/xen/include/asm-powerpc/page.h index 279cfbb2ab..9175f62046 100644 --- a/xen/include/asm-powerpc/page.h +++ b/xen/include/asm-powerpc/page.h @@ -16,6 +16,7 @@ * Copyright (C) IBM Corp. 2005 * * Authors: Hollis Blanchard + * Jimi Xenidis */ #ifndef _ASM_PAGE_H @@ -29,6 +30,7 @@ #include #include +#include #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -- 2.30.2